/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListTaller21Data {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
		System.out.println("Listing Paciente...");
		orm.Paciente[] ormPacientes = lDAOFactory.getPacienteDAO().listPacienteByQuery(null, null);
		int length = Math.min(ormPacientes.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormPacientes[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Prestacion...");
		orm.Prestacion[] ormPrestacions = lDAOFactory.getPrestacionDAO().listPrestacionByQuery(null, null);
		length = Math.min(ormPrestacions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormPrestacions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Diagnostico...");
		orm.Diagnostico[] ormDiagnosticos = lDAOFactory.getDiagnosticoDAO().listDiagnosticoByQuery(null, null);
		length = Math.min(ormDiagnosticos.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormDiagnosticos[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Paciente by Criteria...");
		orm.PacienteCriteria pacienteCriteria = new orm.PacienteCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//pacienteCriteria.pa_id_paciente.eq();
		pacienteCriteria.setMaxResults(ROW_COUNT);
		orm.Paciente[] ormPacientes = pacienteCriteria.listPaciente();
		int length =ormPacientes== null ? 0 : Math.min(ormPacientes.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormPacientes[i]);
		}
		System.out.println(length + " Paciente record(s) retrieved."); 
		
		System.out.println("Listing Prestacion by Criteria...");
		orm.PrestacionCriteria prestacionCriteria = new orm.PrestacionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//prestacionCriteria.pr_id_prestacion.eq();
		prestacionCriteria.setMaxResults(ROW_COUNT);
		orm.Prestacion[] ormPrestacions = prestacionCriteria.listPrestacion();
		length =ormPrestacions== null ? 0 : Math.min(ormPrestacions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormPrestacions[i]);
		}
		System.out.println(length + " Prestacion record(s) retrieved."); 
		
		System.out.println("Listing Diagnostico by Criteria...");
		orm.DiagnosticoCriteria diagnosticoCriteria = new orm.DiagnosticoCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//diagnosticoCriteria.di_id_diagnostico.eq();
		diagnosticoCriteria.setMaxResults(ROW_COUNT);
		orm.Diagnostico[] ormDiagnosticos = diagnosticoCriteria.listDiagnostico();
		length =ormDiagnosticos== null ? 0 : Math.min(ormDiagnosticos.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormDiagnosticos[i]);
		}
		System.out.println(length + " Diagnostico record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListTaller21Data listTaller21Data = new ListTaller21Data();
			try {
				listTaller21Data.listTestData();
				//listTaller21Data.listByCriteria();
			}
			finally {
				orm.Taller21PersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
